package org.test;

import org.junit.Test;

import com.dangdang.ddframe.rdb.sharding.parsing.lexer.Lexer;
import com.dangdang.ddframe.rdb.sharding.parsing.lexer.analyzer.Dictionary;
import com.dangdang.ddframe.rdb.sharding.parsing.lexer.dialect.mysql.MySQLKeyword;
import com.dangdang.ddframe.rdb.sharding.parsing.lexer.token.Assist;
import com.dangdang.ddframe.rdb.sharding.parsing.lexer.token.Token;
import com.dangdang.ddframe.rdb.sharding.parsing.lexer.token.TokenType;

public class AppTest001 {

	// 词法解析器
	@Test
	public void testLexer() {
		Dictionary dictionary = new Dictionary(MySQLKeyword.values());
		Lexer lexer = new Lexer("select * from dual", dictionary);
		for (;;) {
			lexer.nextToken();
			Token token = lexer.getCurrentToken();
			TokenType type = token.getType();
			System.out.println(token.getLiterals() + type);
			if (type == Assist.END)
				break;
		}
	}
}
